﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using AutoShuntingSchedule.UI.Controls;
using FileLibrary;
using FileLibrary.Models;
using Sunny.UI;

namespace AutoShuntingSchedule.UI.Forms
{
    public partial class SysDataForm : UIPage
    {
        public SysDataForm()
        {
            InitializeComponent();
        }

        private void SysDataForm_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            //MainFormCommonLib.Instance.SetLocationToForm(ClientRectangle);
            //MainFormCommonLib.Instance.ActiveProgressIndicator(true);

            var dictionary = FileManage.Instance.ClassDictionary;
            foreach (var pair in dictionary)
            {
                var key = pair.Key;
                var value = pair.Value;

                var fDataGridView = new FDataGridView()
                {
                    Dock = DockStyle.Fill,
                    Text = key
                };

                var list = new List<FileModel>();
                foreach (var fileMode in FileManage.Instance.FileModes)
                {
                    var fileModeValue = fileMode.Value;
                    if (fileModeValue.GetType() == value)
                    {
                        list.Add(fileModeValue);
                    }
                }

                fDataGridView.SetDataSource(key, value, list);
                this.uiTabControl1.AddPage(fDataGridView);
            }

            //MainFormCommonLib.Instance.ActiveProgressIndicator(false);
            this.Validate();

        }
    }
}
